package cn.net.ecode.modules.sys.entity;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

import cn.net.ecode.common.utils.EntityUtils;

/**
 * JSON实体类，用于传递非model的参数 <p>
 * 设置3类参数，字符串(存储单个参数)，Map(存储一组参数)，List(存储参数集合)
 * @title: JsonEntity.java
 * @package cn.net.ecode.modules.sys.entity
 * @author 刘保全
 * @version 2014-8-19
 */
@SuppressWarnings("rawtypes")
public class JsonEntity implements Serializable {

	private static final long serialVersionUID = 4359001485924539880L;

	public JsonEntity() {
		
	}

	/***
	 * JS使用
	 * <p>
	 * var entity = new Object();
	 * <p>
	 * entity.strParam="需要传递的字符串";
	 * <p>
	 * $.post(url,entity,function(data){},"json");
	 */
	private String strParam; // 字符串
	
	/***
	 * JS使用
	 * <p>
	 * var entity = new Object();
	 * <p>
	 * entity.mapParam={"key1":"value1","key2":"value2",.....};
	 * <p>
	 * $.post(url,entity,function(data){},"json");
	 */
	private Map<String, String> mapParam; // Map对象
	
	/***
	 * JS使用
	 * <p>
	 * var entity = new Object();
	 * <p>
	 * entity.listParam=[{"key1":"value1",...},{"key1":"value1",...},....];
	 * <p>
	 * $.post(url,entity,function(data){},"json");
	 */
	private List<Map<String, String>> listParam; // List集合

	private List listEntity; // List实体集合，用于批量插入，如批量数据导入

	public String getStrParam() {
		return strParam;
	}

	public void setStrParam(String strParam) {
		this.strParam = strParam;
	}

	public Map<String, String> getMapParam() {
		return mapParam;
	}

	public void setMapParam(Map<String, String> mapParam) {
		this.mapParam = mapParam;
	}

	public List<Map<String, String>> getListParam() {
		return listParam;
	}

	public void setListParam(List<Map<String, String>> listParam) {
		this.listParam = listParam;
	}

	/**
	 * 获取实体
	 * 
	 * @param t 实体类
	 * @return
	 */
	public <T> List<T> getListParam(Class<T> t) {
		List<T> resultList = null;
		try {
			resultList = EntityUtils.conver(listParam, t);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return resultList;
	}

	public List getListEntity() {
		return listEntity;
	}

	public void setListEntity(List listEntity) {
		this.listEntity = listEntity;
	}

}
